﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace EmbeddedLanguage
{
    public class JSFunction //: IComparable<JSFunction>
    {
        public string FunctionName;

        public string ExplicitScript { get; set; }

        private Expression _exp;
        public Expression Expression
        {
            get
            {
                return _exp;
            }
            set
            {
                _exp = value;
                
            }
        }

        public List<string> ArgNames;

        public List<string> ArgNamesNN
        {
            get
            {
                if (ArgNames == null) ArgNames = new List<string>();
                return ArgNames;
            }
        }

        public void Process(NestedString ns)
        {
            var expressionVisitor = new ExpressionToJSProcessor
            {
                Function = this,
                CurrentNestedString = ns,
            };
            expressionVisitor.Visit(this.Expression);
        }
    }
}
